

/***
Workshop Example
================

Subheader, Markdown syntax
--------------------------


This is a normal paragraph. We are trying to import 
an image to our document. The image is stored in the 
working directory. The syntax for importing an image 
is as follows

     ![explain this figure](path/to/imagefile)

![explain this figure](example.png)


There is a better way to include an image in the document. completely automatic!
Let's start by creating a histogram and then using the `img` command:

***/

sysuse auto, clear
hist price

/***
### Including an image

Next, I am using the `img` command to automatically include the image in the 
document 
***/

img, title("Figure 1. say something about this figure")


/***
Writing dynamic text
--------------------

We can use the `txt` command to write dynamic text in our documnt.
***/

summarize price

/***
I can use the `return list` command to see what macros are returned by the 
`summarize` command. These values will be printed:
***/

return list


txt "the mean of Price variable is " r(mean)

txt "the minimum value is " r(min) " and the maximum is "  r(max)



/***
Writing dynamic table
--------------------

We can use the `tbl` command to write dynamic tables. The `tbl` command generates 
the tables the same way Stata defines a matrix. To learn how Stata generate a 
matrix type:

    help matrix
***/

tbl ("*italic 1*", "*italic 2*", "*italic 3*" \ ///
     "**boldtext1**", 100, 1000 \         ///
	 "**boldtext2**", 22, 222   \         ///
	 "**boldtext3**", 3948, 3948), title("Table 1. Styling a table")


tbl ({l}"Left", {c}"Centered", {r}"Right" \ c(os),  c(machine_type), c(username))


/***
#### Adding mathematical symbols in the dynamic table

We have to use the LaTeX mathematical syntax, but they will be automatically 
converted in all documents generated by MarkDoc
***/

tbl ("$\\beta$", "$95\\%$ Confidence Interval" \ "values...", "values...")

tbl ("$\\beta$", "$\\epsilon$" \ "$\\sum$", "$\\prod$")


/***
Creating a summary table
------------------------

I will use the macros returned from `summarize` command to build a nice table 
in my document:
***/

summarize price
return list
tbl ("Variable", "Observations", "Mean", "SD" \  ///
     "__price__", r(N), %9.2f r(mean), %9.2f r(sd))



